<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
         <menu-item @bigtext="handle" :parr="parr" :num="num"></menu-item>
    </div>
</body>
<script>
//子
Vue.component('menu-item',{
    props:['parr','num'],
    template:`
    <div>
        <h1>子组件 {{num}}</h1>
        <p v-for="item in parr">{{ item }}</p>
        <button @click="test">子按钮</button>
    </div>
    `,
    methods:{
        test(){
            console.log( 'test.....');
            //this.parr.push('龙龟')
            //this.parr[0] = '提莫'
            //this.num++
            // 调用父事件
            this.$emit('bigtext', 100)
        }
    }
});

// 父
var vm = new Vue({
    el: "#app",
    data: {
        parr: ['temo','德玛','js','狐狸'],
        num: 88
    },
    methods:{
        handle(v){
            console.log('这里是父的函数--->',v );
            this.num = v 
        }
    }
});
</script>
</html>